<div class="row-fluid">
    <div class="span12">                    
        <div class="head">
            <div class="isw-grid"></div>
            <h1><?php echo $this->pageTitle;?></h1>
			<a href="<?php echo PIUrl::createUrl('/admincp/acticle/create',array('category'=>$categorya->id));?>" class="btn btn-success btn-addSlide" type="button" style="float:right;margin:4px;"><?php echo translate('Thêm mới ').$categorya->name;?></a>
            <div class="clear"></div>
        </div>
        <div class="block-fluid table-sorting">
		<div id="tSortable_wrapper" class="dataTables_wrapper" role="grid">
			<div class="dataTables_filter" id="tSortable_filter" style="float:left;width: 100%;">
			<form id="searchFilerForm" action="<?php echo $action;?>" method="GET">
				<label>Tìm kiếm theo tên: <input style="width:300px" type="text"  name="name" value="<?php if(isset($_GET['name'])) echo $_GET['name']?>"></label>
			</form>
			</div>
            
			<table cellpadding="0" cellspacing="0" width="100%" class="table dataTable">
                <thead>
                    <tr>                                    
                        <th style="text-align:center" width="5%">STT</th>
                        <th style="text-align:center" width="10%">Hình ảnh</th>
                        <th width="30%">Tên sản phẩm</th>
                        <th width="15%">Danh mục</th>
                        <th width="15%">Ngày tạo</th>
                        <th style="text-align:center" width="10%">Chức năng</th>                                    
                    </tr>
                </thead>
                <tbody>
				<?php $i=1; if(!empty($model)): foreach($model as $item):?>
					<?php
						$class = 'badge-inverse';
						if($item->ActicleCategories->id == 2)
							$class = 'badge-info';
						elseif($item->ActicleCategories->id == 3)
							$class = 'badge-success';
						elseif($item->ActicleCategories->id == 4)
							$class = 'badge-important';
					?>
                    <tr>                                    
                        <td style="text-align:center"><?php echo $i;?></td>
                        <td style="text-align:center"><a class="fancybox" rel="group" href="<?php echo Yii::app()->baseUrl;?>/upload/acticles/<?php echo $item->getImage();?>"><img rel="<?php echo $item->getUnit();?>" src="<?php echo Yii::app()->baseUrl.'/upload/image.php?width=50&image='.Yii::app()->baseUrl.'/upload/acticles/'.$item->getImage();?>" width="50" class="img-polaroid"></a></td>
                        <td><?php echo $item->name;?></td>
                        <td style="text-align: center"><span class="badge <?php echo $class;?>"><?php echo $item->ActicleCategories->name;?></span></td>
                        <td><?php echo date('d/m/Y H:s:i',$item->created);?></td>
                        <td style="text-align:center">
                            <a href="<?php echo PIUrl::createUrl('/admincp/acticle/update/id/'.$item->id);?>" class="btn btn-mini btn-updateCat" type="button">Cập nhật</a>
                            <a href="<?php echo PIUrl::createUrl('/admincp/acticle/delete/id/'.$item->id);?>" onclick="return confirm('Bạn thực sự muốn xóa?')" class="btn btn-mini btn-warning" type="button">Xóa</a>
					</td>
                    </tr>
				<?php $i++; endforeach;?>
				<?php else:?>
				<tr>                                    
                    <td colspan="6" style="text-align:center"><?php echo translate('Hiện tại không có '.$categorya->name.' nào.');?></td>
                </tr>
				<?php endif;?>
                </tbody>
            </table>
			<div class="dataTables_paginate paging_full_numbers" id="tSortable_2_paginate">
			<?php //dump($this->widget('CLinkPager'));?>
				<?php $this->widget('CLinkPager', array(
					'pages' => $pages,
					'header'=>'',
					'nextPageLabel'=>'Sau &gt;',
					'prevPageLabel'=>'&lt; Trước',
					'firstPageLabel'=>'&lt;&lt; Đầu',
					'lastPageLabel'=>'Cuối &gt;&gt;'
				)) ?>
			</div>
			</div>
			<div class="clear"></div>
        </div>
    </div>                                
</div>
<script>
$(document).ready(function(){
	$('#searchFilerForm').submit(function(){
		var name = $(this).find('input').val();
		var action = $(this).attr('action');
		if(name != '')
		var action = $(this).attr('action')+'&name='+name;
		window.location.href = action;
		return false;
	});
});
</script>